﻿<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="tabSequences.ascx.cs"
    Inherits="CustomerService.SequenceTab" %>
<table>
    <tr>
        <td>
            <asp:ListView ID="lvSequenceList" runat="server" OnSelectedIndexChanging="SequenceListSelectedIndexChanging">
                <LayoutTemplate>
                    <table>
                        <tr id="itemPlaceholder" runat="server"></tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr id="Tr1" runat="server">
                        <td style="border-bottom: 1px solid black;">
                            <asp:LinkButton ID="btnSelectSequence" runat="server" Text='<%# Eval("Sequence.Description") %>' CommandName="Select" /><br />
                            <%# Eval("SequenceStatus.Description") %><br />
                            <%# Eval("CanceledReason.Description") %><br />
                        </td>
                    </tr>
                </ItemTemplate>
                <SelectedItemTemplate>
                    <tr id="Tr1" runat="server">
                        <td style="border-bottom: 1px solid black; background: yellow;">
                            <asp:LinkButton ID="btnSelectSequence" runat="server" Text='<%# Eval("Sequence.Description") %>' CommandName="Select" /><br />
                            <%# Eval("SequenceStatus.Description") %><br />
                            <%# Eval("CanceledReason.Description") %><br />
                        </td>
                    </tr>
                </SelectedItemTemplate>
            </asp:ListView>
        </td>
        <td>
            <asp:Repeater ID="repeater1" runat="server">
                <HeaderTemplate>
                    <table id="SequenceTable">
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <asp:Repeater ID="repeater2" runat="server" DataSource="<%#Container.DataItem %>">
                            <ItemTemplate>
                                <td class="SequenceRow">
                                    <table>
                                        <tr>
                                            <td>
                                                <asp:HiddenField ID="txtSequenceStepID" runat="server" Value=<%# Eval("SequenceStepID") %> />
                                                <span style="display:<%#((short)Eval("Delay") > 0) ? "inline" : "none" %>;">
                                                    Wait <asp:TextBox ID="txtSequenceDelay" runat="server" Text=<%# Eval("Delay") %> /> days.<br />
                                                    Then create
                                                </span>
                                                <%# ((short)Eval("Delay") > 0) ? string.Empty : "Create"%> 
                                                an order with the following items 
                                                <span style="display:<%#((short)Eval("RecurrenceCount") > 1) ? "inline" : "none" %>;">
                                                     <%#Eval("RecurrenceCount").ToString()  %> times with 
                                                     <asp:TextBox ID="txtSequenceTerm" runat="server" Text=<%# Eval("RecurrenceTerm") %> />
                                                     days between each order.
                                                </span>
                                                <%# (Eval("NextTriggerDate") != null) ? "<br />The next order will be created on " + ((DateTime)Eval("NextTriggerDate")).ToShortDateString() : string.Empty %>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="5">
                                                <asp:Repeater ID="repeater3" runat="server" DataSource="<%# ((CustomerService.tblSequenceStep)Container.DataItem).SequenceStepProducts %>">
                                                    <HeaderTemplate>
                                                        <table style="border-top: 1px solid black;">
                                                            <tr style="font-weight: bold;">
                                                                <td>Qty</td>
                                                                <td>Product</td>
                                                                <td>Price</td>
                                                            </tr>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td>
                                                                <%#Eval("Qty") %>
                                                            </td>
                                                            <td>
                                                                <%#Eval("Product.ShortName") %>
                                                            </td>
                                                            <td>
                                                                <asp:TextBox id="txtSequenceProductPrice" runat="server"
                                                                    text=<%# (Eval("Price") == null) ? string.Empty : ((decimal)Eval("Price")).ToString("C") %> />
                                                            </td>
                                                            <td style="display:none;">
                                                                <asp:HiddenField ID="txtSequenceStepProductID" runat="server" 
                                                                    Value=<%# Eval("SequenceStepProductID") %> />
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        </table>
                                                    </FooterTemplate>
                                                </asp:Repeater>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td style="vertical-align:middle">
                                    <nobr>--></nobr>
                                </td>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Button ID="btnCancel" runat="server" OnClick="brnCancel_Click" Text="Cancel" />
        </td>
    </tr>
</table>
